#!/usr/bin/perl

$file = $ARGV[0];

open(RH,"<$file");
	 # slurp everythin into one scalar
	 # my $content1 = do { local( $/ ) ; <RH> } ;
my @content = <RH>;
close RH;

$content = &slurp_from_array_into_scalar(@content);

$content =~ s/<!--(.*?)-->//igms;					# remove comments
$content =~ s/<script.*?>(.*?)<\/script>//igsm;		# remove scripts
$content =~ s/<style.*?>(.*?)<\/style>//igsm;		# remove style
$content =~ s/<.*?>//igms;							# remove html tags
$content = &html_to_ascii_parser($content);

foreach $line ( split(//, $content) ){
	$c++;
	if ($c >= "120") {
		$line =~ s/$line/$line\n/;
		$c = "0";
	}
	print $line;
	
}

sub slurp_from_array_into_scalar {
	
	foreach $content (@_) {
		$html_one_line = $html_one_line . $content;
	}

	return $html_one_line;
	
}

sub html_to_ascii_parser() {

	my $HTML = @_[0];
	my(@HTMLPage, $SymbLine, $ascii, $html);

	$HTML =~ s/&nbsp;/ /g;
	$HTML =~ s/\s\s*/ /g;
	$HTML =~ s/\n\s*\n\s*/\n\n/g;
	$HTML =~ s/\n */\n/g;
	
	foreach $SymbLine (&HTMLSymb) {
		($ascii, $html) = split(/\s\s*/,$SymbLine);
		$HTML =~ s/$html/$ascii/g;
		$HTML =~ s/'//g;
		$HTML =~ s/`//g;
		$HTML =~ s/&#180;//;
	}
	
	return($HTML);
	
	# HTML Codes
	sub HTMLSymb() {
		return (
		"&	&amp;",
		"\"	&quot;",
		"<	&lt;",
		">	&gt;",
		"©	&copy;",
		"®	&reg;",
		"Æ	&AElig;",
		"Á	&Aacute;",
		"Â	&Acirc;",
		"À	&Agrave;",
		"Å	&Aring;",
		"Ã	&Atilde;",
		"Ä	&Auml;",
		"Ç	&Ccedil;",
		"Ð	&ETH;",
		"É	&Eacute;",
		"Ê	&Ecirc;",
		"È	&Egrave;",
		"Ë	&Euml;",
		"Í	&Iacute;",
		"Î	&Icirc;",
		"Ì	&Igrave;",
		"Ï	&Iuml;",
		"Ñ	&Ntilde;",
		"Ó	&Oacute;",
		"Ô	&Ocirc;",
		"Ò	&Ograve;",
		"Ø	&Oslash;",
		"Õ	&Otilde;",
		"Ö	&Ouml;",
		"Þ	&THORN;",
		"Ú	&Uacute;",
		"Û	&Ucirc;",
		"Ù	&Ugrave;",
		"Ü	&Uuml;",
		"Ý	&Yacute;",
		"á	&aacute;",
		"â	&acirc;",
		"æ	&aelig;",
		"à	&agrave;",
		"å	&aring;",
		"ã	&atilde;",
		"ä	&auml;",
		"ç	&ccedil;",
		"é	&eacute;",
		"ê	&ecirc;",
		"è	&egrave;",
		"ð	&eth;",
		"ë	&euml;",
		"í	&iacute;",
		"î	&icirc;",
		"ì	&igrave;",
		"ï	&iuml;",
		"ñ	&ntilde;",
		"ó	&oacute;",
		"ô	&ocirc;",
		"ò	&ograve;",
		"ø	&oslash;",
		"õ	&otilde;",
		"ö	&ouml;",
		"ß	&szlig;",
		"þ	&thorn;",
		"ú	&uacute;",
		"û	&ucirc;",
		"ù	&ugrave;",
		"ü	&uuml;",
		"ý	&yacute;",
		"ÿ	&yuml;",
		" 	&#160;",
		"¡	&#161;",
		"¢	&#162;",
		"£	&#163;",
		"¥	&#165;",
		"¦	&#166;",
		"§	&#167;",
		"¨	&#168;",
		"©	&#169;",
		"ª	&#170;",
		"«	&#171;",
		"¬	&#172;",
		"­	&#173;",
		"®	&#174;",
		"¯	&#175;",
		"°	&#176;",
		"±	&#177;",
		"²	&#178;",
		"³	&#179;",
		"´	&#180;",
		"µ	&#181;",
		"¶	&#182;",
		"·	&#183;",
		"¸	&#184;",
		"¹	&#185;",
		"º	&#186;",
		"»	&#187;",
		"¼	&#188;",
		"½	&#189;",
		"¾	&#190;",
		"¿	&#191;",
		"×	&#215;",
		"Þ	&#222;",
		"÷	&#247;",
		"   &#94;",
		"ü  &#252;",

		);
		}# sub HTMLSymb() {}

}# sub html_to_ascii_parser() {}
########### Soubroutine zum extrahieren von html inforamtionen